<?php

require_once 'inc/common.php';
$checkins = array();
$name = $db->q1('
	SELECT name
	FROM users
	WHERE fbid = ?
	AND fbid IN (
		SELECT friend_fbid
		FROM friends
		WHERE user_fbid = ?
	)
', $_GET['fbid'], $_SESSION['me']['fbid']);
if ($name) {
	$fbcheckins = $fb->api("/$_GET[fbid]/checkins?limit=5000");
	foreach ($fbcheckins['data'] as $c) {
		$checkins[] = array('title' => "{$c['place']['name']} ($name)", 'lat' => $c['place']['location']['latitude'], 'lng' => $c['place']['location']['longitude']);
	}
}
header('Content-Type: application/json');
echo json_encode($checkins);

?>